import re 												#导入正则表达式库
from bs4 import BeautifulSoup								#导入库
email_id_example = """<br/>
<div>The below HTML has the information that has email ids.</div> 
abc@example.com 
<div>xyz@example.com</div> 
<span>foo@example.com</span> 
"""													#定义字符串
soup = BeautifulSoup(email_id_example,'lxml')					#创建对象
emailid_regexp=re.compile("\w+@\w+\.\w+")					# regexp 表达式对象
first_email_id = soup.find(text=emailid_regexp)					#查找符合正则表达式的结果
print(first_email_id)										#输出结果
